<?php
class Payment_Adapter 
{
    private static $_instance;

    public static function set($name,$configs)
    {
        if(!$name) throw new Payment_Exception('适配器名称不为空');      

        $adapterName = 'Payment_Adapter_' . ucwords($name);
        $classFile = dirname(__FILE__).DIRECTORY_SEPARATOR.'Adapter'.DIRECTORY_SEPARATOR.ucwords($name).'.php';

        if(!is_file($classFile)) throw new Payment_Exception('适配器类'.$className.'不存在');

        require_once $classFile;

        return self::$_instance = new $adapterName($configs); 
    }
}

?>
